/**
* @title: 离职页
* @description:
* @author JUN
*/
<template>
	<view class="leave">
		
		<!-- 背景图片 -->
		<bg class="bg"></bg>
		<view class="content">
			<h2>离职后需要重新绑定团购码</h2>
			<u-form class="form" :model="form" ref="uForm" label-width="130" :border-bottom="false">
				<u-form-item label="团购码">
					<u-input :border="true" border-color="#403811" v-model="form.code" placeholder="请输入团餐码" placeholder-style="color: #403811;" />
				</u-form-item>
				<u-button :custom-style="customStyle" @click="submit" size="medium" type="success" throttle-time>提交</u-button>
			</u-form>
		</view>
		
		<!-- 提示 -->
		<u-toast ref="uToast" />
		
		<!-- loading效果 -->
		<wyb-loading ref="loading"/>
	</view>
</template>

<script>
	import * as api from "@/api/apiList/user/user.js"
	import bg from '@/pages/regiser/components/bg.vue'
	export default {
		components:{
			bg
		},
		data() {
			return {
				form: {
					code: "" //团购码
				},
				customStyle: {//提交按钮样式
					marginTop: '20rpx',
					backgroundColor:"#f43a3d",
					color:"#fff"
				},
			}
		},

		methods: {
			async API_updateEnterpriseCode(code) {
				let result = {
					param: {
						code //团购码
					}
				}
				return await api.updateEnterpriseCode(result)
			},
			async submit() { //提交
				this.$refs.loading.showLoading() // 显示
				
				let res = await this.API_updateEnterpriseCode(this.form.code)
				if (res.data.code === 1000) {
					this.$refs.uToast.show({ //提示
						title: '登录成功',
						type: 'success'
					})
					uni.navigateTo({ //跳转到首页
						url: '/pages/waitting/waitting'
					});
				} else {
					this.$refs.uToast.show({ //提示
						title: '失败',
						type: 'error'
					})
				}
				this.$refs.loading.hideLoading() // 隐藏
			}
		}
	}
</script>

<style lang="scss" scoped>
	.leave {
		height: 100%;
		text-align: center;
		display: flex;
		font-size: 31rpx;
		justify-content: center;
		flex-direction: column;
		align-items: center;

		.bg {
			//背景
			position: absolute;
			z-index: -999;
			width: 100%;
			height: 100%;
		}
		.content{
			position: relative;
			z-index: 1;
			color: #403811;
			h2 {
				margin-bottom: 35rpx;
			}
		}
		
	}
</style>
